<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>s3.parsers</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="s3-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="s3-module.html">Package&nbsp;s3</a> ::
        Module&nbsp;parsers
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="s3.parsers-pysrc.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<h1 class="epydoc">Source Code for <a href="s3.parsers-module.html">Module s3.parsers</a></h1>
<pre class="py-src">
<tt class="py-lineno">  1</tt>  <tt class="py-line"><tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno">  2</tt>  <tt class="py-line">    <tt class="py-keyword">import</tt> <tt class="py-name">cElementTree</tt> <tt class="py-name">as</tt> <tt class="py-name">et</tt> </tt>
<tt class="py-lineno">  3</tt>  <tt class="py-line"><tt class="py-keyword">except</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno">  4</tt>  <tt class="py-line">    <tt class="py-keyword">from</tt> <tt class="py-name">elementtree</tt> <tt class="py-keyword">import</tt> <tt class="py-name">ElementTree</tt> <tt class="py-name">as</tt> <tt class="py-name">et</tt> </tt>
<tt class="py-lineno">  5</tt>  <tt class="py-line"> </tt>
<tt class="py-lineno">  6</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt id="link-0" class="py-name" targets="Package s3=s3-module.html"><a title="s3" class="py-name" href="#" onclick="return doclink('link-0', 's3', 'link-0');">s3</a></tt></tt> </tt>
<tt class="py-lineno">  7</tt>  <tt class="py-line"> </tt>
<tt class="py-lineno">  8</tt>  <tt class="py-line"> </tt>
<tt class="py-lineno">  9</tt>  <tt class="py-line"><tt id="link-1" class="py-name" targets="Variable s3.parsers.xmlns=s3.parsers-module.html#xmlns"><a title="s3.parsers.xmlns" class="py-name" href="#" onclick="return doclink('link-1', 'xmlns', 'link-1');">xmlns</a></tt></tt> <tt class="py-op">=</tt> <tt class="py-string">'http://s3.amazonaws.com/doc/'</tt> <tt class="py-op">+</tt> <tt id="link-2" class="py-name"><a title="s3" class="py-name" href="#" onclick="return doclink('link-2', 's3', 'link-0');">s3</a></tt></tt><tt class="py-op">.</tt><tt id="link-3" class="py-name" targets="Variable s3.VERSION=s3-module.html#VERSION"><a title="s3.VERSION" class="py-name" href="#" onclick="return doclink('link-3', 'VERSION', 'link-3');">VERSION</a></tt></tt> <tt class="py-op">+</tt> <tt class="py-string">'/'</tt> </tt>
<tt class="py-lineno"> 10</tt>  <tt class="py-line"> </tt>
<a name="parseError"></a><div id="parseError-def"><tt class="py-lineno"> 11</tt> <a class="py-toggle" href="#" id="parseError-toggle" onclick="return toggle('parseError');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="s3.parsers-module.html#parseError">parseError</a><tt class="py-op">(</tt><tt class="py-param">xml</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="parseError-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="parseError-expanded"><tt class="py-lineno"> 12</tt>  <tt class="py-line">    <tt class="py-docstring">'''</tt> </tt>
<tt class="py-lineno"> 13</tt>  <tt class="py-line"><tt class="py-docstring">    Parse the response XML if error occured, and creates an SQSError exception.</tt> </tt>
<tt class="py-lineno"> 14</tt>  <tt class="py-line"><tt class="py-docstring">    </tt> </tt>
<tt class="py-lineno"> 15</tt>  <tt class="py-line"><tt class="py-docstring">    @param xml: The XML error response</tt> </tt>
<tt class="py-lineno"> 16</tt>  <tt class="py-line"><tt class="py-docstring">    @type  xml: string</tt> </tt>
<tt class="py-lineno"> 17</tt>  <tt class="py-line"><tt class="py-docstring">    @return:    Returns the S3Error exception</tt> </tt>
<tt class="py-lineno"> 18</tt>  <tt class="py-line"><tt class="py-docstring">    @rtype:     S3Error</tt> </tt>
<tt class="py-lineno"> 19</tt>  <tt class="py-line"><tt class="py-docstring">    '''</tt> </tt>
<tt class="py-lineno"> 20</tt>  <tt class="py-line">    <tt class="py-name">root</tt> <tt class="py-op">=</tt> <tt class="py-name">et</tt><tt class="py-op">.</tt><tt class="py-name">fromstring</tt><tt class="py-op">(</tt><tt class="py-name">xml</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 21</tt>  <tt class="py-line">    <tt class="py-name">code</tt> <tt class="py-op">=</tt> <tt class="py-name">root</tt><tt class="py-op">.</tt><tt class="py-name">find</tt><tt class="py-op">(</tt><tt class="py-string">'Code'</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">text</tt> </tt>
<tt class="py-lineno"> 22</tt>  <tt class="py-line">    <tt class="py-name">message</tt> <tt class="py-op">=</tt> <tt class="py-name">root</tt><tt class="py-op">.</tt><tt class="py-name">find</tt><tt class="py-op">(</tt><tt class="py-string">'Message'</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">text</tt> </tt>
<tt class="py-lineno"> 23</tt>  <tt class="py-line">    <tt class="py-name">resource_node</tt> <tt class="py-op">=</tt> <tt class="py-name">root</tt><tt class="py-op">.</tt><tt class="py-name">find</tt><tt class="py-op">(</tt><tt class="py-string">'Resource'</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 24</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">resource_node</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno"> 25</tt>  <tt class="py-line">        <tt class="py-name">resource</tt> <tt class="py-op">=</tt> <tt class="py-name">resource_node</tt><tt class="py-op">.</tt><tt class="py-name">text</tt> </tt>
<tt class="py-lineno"> 26</tt>  <tt class="py-line">    <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno"> 27</tt>  <tt class="py-line">        <tt class="py-name">resource</tt> <tt class="py-op">=</tt> <tt class="py-string">''</tt> </tt>
<tt class="py-lineno"> 28</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt id="link-4" class="py-name"><a title="s3" class="py-name" href="#" onclick="return doclink('link-4', 's3', 'link-0');">s3</a></tt></tt><tt class="py-op">.</tt><tt id="link-5" class="py-name" targets="Class s3.errors.S3Error=s3.errors.S3Error-class.html"><a title="s3.errors.S3Error" class="py-name" href="#" onclick="return doclink('link-5', 'S3Error', 'link-5');">S3Error</a></tt></tt><tt class="py-op">(</tt><tt class="py-name">code</tt><tt class="py-op">,</tt> <tt class="py-name">message</tt><tt class="py-op">,</tt> <tt class="py-name">resource</tt><tt class="py-op">)</tt> </tt>
</div><tt class="py-lineno"> 29</tt>  <tt class="py-line"> </tt>
<tt class="py-lineno"> 30</tt>  <tt class="py-line"> </tt>
<a name="parseGetBucket"></a><div id="parseGetBucket-def"><tt class="py-lineno"> 31</tt> <a class="py-toggle" href="#" id="parseGetBucket-toggle" onclick="return toggle('parseGetBucket');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="s3.parsers-module.html#parseGetBucket">parseGetBucket</a><tt class="py-op">(</tt><tt class="py-param">name</tt><tt class="py-op">,</tt> <tt class="py-param">xml</tt><tt class="py-op">,</tt> <tt class="py-param">connection</tt><tt class="py-op">,</tt> <tt class="py-param">default</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="parseGetBucket-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="parseGetBucket-expanded"><tt class="py-lineno"> 32</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
<tt class="py-lineno"> 33</tt>  <tt class="py-line"><tt class="py-docstring">    Parse the response XML for geting a bucket</tt> </tt>
<tt class="py-lineno"> 34</tt>  <tt class="py-line"><tt class="py-docstring">    </tt> </tt>
<tt class="py-lineno"> 35</tt>  <tt class="py-line"><tt class="py-docstring">    @param name:       The name of the bucket</tt> </tt>
<tt class="py-lineno"> 36</tt>  <tt class="py-line"><tt class="py-docstring">    @type  name:       string</tt> </tt>
<tt class="py-lineno"> 37</tt>  <tt class="py-line"><tt class="py-docstring">    @param xml:        The XML response</tt> </tt>
<tt class="py-lineno"> 38</tt>  <tt class="py-line"><tt class="py-docstring">    @type  xml:        string</tt> </tt>
<tt class="py-lineno"> 39</tt>  <tt class="py-line"><tt class="py-docstring">    @param connection: S3Connection to the server</tt> </tt>
<tt class="py-lineno"> 40</tt>  <tt class="py-line"><tt class="py-docstring">    @type  connection: S3Connection</tt> </tt>
<tt class="py-lineno"> 41</tt>  <tt class="py-line"><tt class="py-docstring">    @param default:    Default return value if bucket is not found</tt> </tt>
<tt class="py-lineno"> 42</tt>  <tt class="py-line"><tt class="py-docstring">    @type  default:    any</tt> </tt>
<tt class="py-lineno"> 43</tt>  <tt class="py-line"><tt class="py-docstring">    @return:           Bucket if exist or default</tt> </tt>
<tt class="py-lineno"> 44</tt>  <tt class="py-line"><tt class="py-docstring">    @rtype:            S3Bucket</tt> </tt>
<tt class="py-lineno"> 45</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
<tt class="py-lineno"> 46</tt>  <tt class="py-line">    <tt class="py-name">root</tt> <tt class="py-op">=</tt> <tt class="py-name">et</tt><tt class="py-op">.</tt><tt class="py-name">fromstring</tt><tt class="py-op">(</tt><tt class="py-name">xml</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 47</tt>  <tt class="py-line">    <tt class="py-name">names</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
<tt class="py-lineno"> 48</tt>  <tt class="py-line">    <tt class="py-name">buckets</tt> <tt class="py-op">=</tt> <tt class="py-name">root</tt><tt class="py-op">.</tt><tt class="py-name">find</tt><tt class="py-op">(</tt><tt class="py-string">'{%s}Buckets'</tt> <tt class="py-op">%</tt> <tt id="link-6" class="py-name"><a title="s3.parsers.xmlns" class="py-name" href="#" onclick="return doclink('link-6', 'xmlns', 'link-1');">xmlns</a></tt></tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 49</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt class="py-name">bucket</tt> <tt class="py-keyword">in</tt> <tt class="py-name">buckets</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno"> 50</tt>  <tt class="py-line">        <tt class="py-name">names</tt><tt class="py-op">.</tt><tt class="py-name">append</tt><tt class="py-op">(</tt><tt class="py-name">bucket</tt><tt class="py-op">.</tt><tt class="py-name">find</tt><tt class="py-op">(</tt><tt class="py-string">'{%s}Name'</tt> <tt class="py-op">%</tt> <tt id="link-7" class="py-name"><a title="s3.parsers.xmlns" class="py-name" href="#" onclick="return doclink('link-7', 'xmlns', 'link-1');">xmlns</a></tt></tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">text</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 51</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">name</tt> <tt class="py-keyword">in</tt> <tt class="py-name">names</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno"> 52</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt id="link-8" class="py-name"><a title="s3" class="py-name" href="#" onclick="return doclink('link-8', 's3', 'link-0');">s3</a></tt></tt><tt class="py-op">.</tt><tt id="link-9" class="py-name" targets="Class s3.objects.S3Bucket=s3.objects.S3Bucket-class.html"><a title="s3.objects.S3Bucket" class="py-name" href="#" onclick="return doclink('link-9', 'S3Bucket', 'link-9');">S3Bucket</a></tt></tt><tt class="py-op">(</tt><tt class="py-name">name</tt><tt class="py-op">,</tt> <tt id="link-10" class="py-name" targets="Module s3.connection=s3.connection-module.html"><a title="s3.connection" class="py-name" href="#" onclick="return doclink('link-10', 'connection', 'link-10');">connection</a></tt></tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 53</tt>  <tt class="py-line">    <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno"> 54</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">default</tt> </tt>
</div><tt class="py-lineno"> 55</tt>  <tt class="py-line"> </tt>
<a name="parseGetBucketNames"></a><div id="parseGetBucketNames-def"><tt class="py-lineno"> 56</tt> <a class="py-toggle" href="#" id="parseGetBucketNames-toggle" onclick="return toggle('parseGetBucketNames');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="s3.parsers-module.html#parseGetBucketNames">parseGetBucketNames</a><tt class="py-op">(</tt><tt class="py-param">xml</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="parseGetBucketNames-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="parseGetBucketNames-expanded"><tt class="py-lineno"> 57</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
<tt class="py-lineno"> 58</tt>  <tt class="py-line"><tt class="py-docstring">    Parse the response XML for geting a list of bucket names</tt> </tt>
<tt class="py-lineno"> 59</tt>  <tt class="py-line"><tt class="py-docstring">    </tt> </tt>
<tt class="py-lineno"> 60</tt>  <tt class="py-line"><tt class="py-docstring">    @param xml:        The XML response</tt> </tt>
<tt class="py-lineno"> 61</tt>  <tt class="py-line"><tt class="py-docstring">    @type  xml:        string</tt> </tt>
<tt class="py-lineno"> 62</tt>  <tt class="py-line"><tt class="py-docstring">    @return:           list of bucket names</tt> </tt>
<tt class="py-lineno"> 63</tt>  <tt class="py-line"><tt class="py-docstring">    @rtype:            list</tt> </tt>
<tt class="py-lineno"> 64</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
<tt class="py-lineno"> 65</tt>  <tt class="py-line">    <tt class="py-name">root</tt> <tt class="py-op">=</tt> <tt class="py-name">et</tt><tt class="py-op">.</tt><tt class="py-name">fromstring</tt><tt class="py-op">(</tt><tt class="py-name">xml</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 66</tt>  <tt class="py-line">    <tt class="py-name">names</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
<tt class="py-lineno"> 67</tt>  <tt class="py-line">    <tt class="py-name">buckets</tt> <tt class="py-op">=</tt> <tt class="py-name">root</tt><tt class="py-op">.</tt><tt class="py-name">find</tt><tt class="py-op">(</tt><tt class="py-string">'{%s}Buckets'</tt> <tt class="py-op">%</tt> <tt id="link-11" class="py-name"><a title="s3.parsers.xmlns" class="py-name" href="#" onclick="return doclink('link-11', 'xmlns', 'link-1');">xmlns</a></tt></tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 68</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt class="py-name">bucket</tt> <tt class="py-keyword">in</tt> <tt class="py-name">buckets</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno"> 69</tt>  <tt class="py-line">        <tt class="py-name">names</tt><tt class="py-op">.</tt><tt class="py-name">append</tt><tt class="py-op">(</tt><tt class="py-name">bucket</tt><tt class="py-op">.</tt><tt class="py-name">find</tt><tt class="py-op">(</tt><tt class="py-string">'{%s}Name'</tt> <tt class="py-op">%</tt> <tt id="link-12" class="py-name"><a title="s3.parsers.xmlns" class="py-name" href="#" onclick="return doclink('link-12', 'xmlns', 'link-1');">xmlns</a></tt></tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">text</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 70</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">names</tt> </tt>
</div><tt class="py-lineno"> 71</tt>  <tt class="py-line"> </tt>
<tt class="py-lineno"> 72</tt>  <tt class="py-line"> </tt>
<a name="parseListBuckets"></a><div id="parseListBuckets-def"><tt class="py-lineno"> 73</tt> <a class="py-toggle" href="#" id="parseListBuckets-toggle" onclick="return toggle('parseListBuckets');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="s3.parsers-module.html#parseListBuckets">parseListBuckets</a><tt class="py-op">(</tt><tt class="py-param">xml</tt><tt class="py-op">,</tt> <tt class="py-param">connection</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="parseListBuckets-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="parseListBuckets-expanded"><tt class="py-lineno"> 74</tt>  <tt class="py-line">    <tt class="py-docstring">'''Parse the response XML for listing buckets</tt> </tt>
<tt class="py-lineno"> 75</tt>  <tt class="py-line"><tt class="py-docstring">    </tt> </tt>
<tt class="py-lineno"> 76</tt>  <tt class="py-line"><tt class="py-docstring">    @param xml:        The XML response</tt> </tt>
<tt class="py-lineno"> 77</tt>  <tt class="py-line"><tt class="py-docstring">    @type  xml:        string</tt> </tt>
<tt class="py-lineno"> 78</tt>  <tt class="py-line"><tt class="py-docstring">    @param connection: S3Connection to the server</tt> </tt>
<tt class="py-lineno"> 79</tt>  <tt class="py-line"><tt class="py-docstring">    @type  connection: S3Connection</tt> </tt>
<tt class="py-lineno"> 80</tt>  <tt class="py-line"><tt class="py-docstring">    @return:           List of buckets</tt> </tt>
<tt class="py-lineno"> 81</tt>  <tt class="py-line"><tt class="py-docstring">    @rtype:            list</tt> </tt>
<tt class="py-lineno"> 82</tt>  <tt class="py-line"><tt class="py-docstring">    '''</tt> </tt>
<tt class="py-lineno"> 83</tt>  <tt class="py-line">    <tt class="py-name">root</tt> <tt class="py-op">=</tt> <tt class="py-name">et</tt><tt class="py-op">.</tt><tt class="py-name">fromstring</tt><tt class="py-op">(</tt><tt class="py-name">xml</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 84</tt>  <tt class="py-line">    <tt class="py-name">buckets_list</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
<tt class="py-lineno"> 85</tt>  <tt class="py-line">    <tt class="py-name">buckets</tt> <tt class="py-op">=</tt> <tt class="py-name">root</tt><tt class="py-op">.</tt><tt class="py-name">find</tt><tt class="py-op">(</tt><tt class="py-string">'{%s}Buckets'</tt> <tt class="py-op">%</tt> <tt id="link-13" class="py-name"><a title="s3.parsers.xmlns" class="py-name" href="#" onclick="return doclink('link-13', 'xmlns', 'link-1');">xmlns</a></tt></tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 86</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt class="py-name">bucket</tt> <tt class="py-keyword">in</tt> <tt class="py-name">buckets</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno"> 87</tt>  <tt class="py-line">        <tt class="py-name">buckets_list</tt><tt class="py-op">.</tt><tt class="py-name">append</tt><tt class="py-op">(</tt><tt id="link-14" class="py-name"><a title="s3" class="py-name" href="#" onclick="return doclink('link-14', 's3', 'link-0');">s3</a></tt></tt><tt class="py-op">.</tt><tt id="link-15" class="py-name"><a title="s3.objects.S3Bucket" class="py-name" href="#" onclick="return doclink('link-15', 'S3Bucket', 'link-9');">S3Bucket</a></tt></tt><tt class="py-op">(</tt><tt class="py-name">bucket</tt><tt class="py-op">.</tt><tt class="py-name">find</tt><tt class="py-op">(</tt><tt class="py-string">'{%s}Name'</tt> <tt class="py-op">%</tt> <tt id="link-16" class="py-name"><a title="s3.parsers.xmlns" class="py-name" href="#" onclick="return doclink('link-16', 'xmlns', 'link-1');">xmlns</a></tt></tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">text</tt><tt class="py-op">,</tt> <tt id="link-17" class="py-name"><a title="s3.connection" class="py-name" href="#" onclick="return doclink('link-17', 'connection', 'link-10');">connection</a></tt></tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 88</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">buckets_list</tt> </tt>
</div><tt class="py-lineno"> 89</tt>  <tt class="py-line">         </tt>
<a name="parseListKeys"></a><div id="parseListKeys-def"><tt class="py-lineno"> 90</tt> <a class="py-toggle" href="#" id="parseListKeys-toggle" onclick="return toggle('parseListKeys');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="s3.parsers-module.html#parseListKeys">parseListKeys</a><tt class="py-op">(</tt><tt class="py-param">xml</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="parseListKeys-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="parseListKeys-expanded"><tt class="py-lineno"> 91</tt>  <tt class="py-line">    <tt class="py-docstring">'''Parse the response XML for listing objects in bucket</tt> </tt>
<tt class="py-lineno"> 92</tt>  <tt class="py-line"><tt class="py-docstring">    </tt> </tt>
<tt class="py-lineno"> 93</tt>  <tt class="py-line"><tt class="py-docstring">    @param xml:    The XML response</tt> </tt>
<tt class="py-lineno"> 94</tt>  <tt class="py-line"><tt class="py-docstring">    @type  xml:    string</tt> </tt>
<tt class="py-lineno"> 95</tt>  <tt class="py-line"><tt class="py-docstring">    @return:       List of object keys</tt> </tt>
<tt class="py-lineno"> 96</tt>  <tt class="py-line"><tt class="py-docstring">    @rtype:        list</tt> </tt>
<tt class="py-lineno"> 97</tt>  <tt class="py-line"><tt class="py-docstring">    '''</tt> </tt>
<tt class="py-lineno"> 98</tt>  <tt class="py-line">    <tt class="py-name">root</tt> <tt class="py-op">=</tt> <tt class="py-name">et</tt><tt class="py-op">.</tt><tt class="py-name">fromstring</tt><tt class="py-op">(</tt><tt class="py-name">xml</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 99</tt>  <tt class="py-line">    <tt id="link-18" class="py-name" targets="Method s3.objects.S3Bucket.keys()=s3.objects.S3Bucket-class.html#keys,Method s3.service.S3Service.keys()=s3.service.S3Service-class.html#keys"><a title="s3.objects.S3Bucket.keys
s3.service.S3Service.keys" class="py-name" href="#" onclick="return doclink('link-18', 'keys', 'link-18');">keys</a></tt></tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
<tt class="py-lineno">100</tt>  <tt class="py-line">    <tt class="py-name">contents</tt> <tt class="py-op">=</tt> <tt class="py-name">root</tt><tt class="py-op">.</tt><tt class="py-name">findall</tt><tt class="py-op">(</tt><tt class="py-string">'{%s}Contents'</tt> <tt class="py-op">%</tt> <tt id="link-19" class="py-name"><a title="s3.parsers.xmlns" class="py-name" href="#" onclick="return doclink('link-19', 'xmlns', 'link-1');">xmlns</a></tt></tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno">101</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt class="py-name">obj</tt> <tt class="py-keyword">in</tt> <tt class="py-name">contents</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno">102</tt>  <tt class="py-line">        <tt id="link-20" class="py-name"><a title="s3.objects.S3Bucket.keys
s3.service.S3Service.keys" class="py-name" href="#" onclick="return doclink('link-20', 'keys', 'link-18');">keys</a></tt></tt><tt class="py-op">.</tt><tt class="py-name">append</tt><tt class="py-op">(</tt><tt class="py-name">obj</tt><tt class="py-op">.</tt><tt class="py-name">find</tt><tt class="py-op">(</tt><tt class="py-string">'{%s}Key'</tt> <tt class="py-op">%</tt> <tt id="link-21" class="py-name"><a title="s3.parsers.xmlns" class="py-name" href="#" onclick="return doclink('link-21', 'xmlns', 'link-1');">xmlns</a></tt></tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">text</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno">103</tt>  <tt class="py-line">    <tt class="py-name">prefixes</tt> <tt class="py-op">=</tt> <tt class="py-name">root</tt><tt class="py-op">.</tt><tt class="py-name">findall</tt><tt class="py-op">(</tt><tt class="py-string">'{%s}CommonPrefixes'</tt> <tt class="py-op">%</tt> <tt id="link-22" class="py-name"><a title="s3.parsers.xmlns" class="py-name" href="#" onclick="return doclink('link-22', 'xmlns', 'link-1');">xmlns</a></tt></tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno">104</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt class="py-name">prefix</tt> <tt class="py-keyword">in</tt> <tt class="py-name">prefixes</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno">105</tt>  <tt class="py-line">        <tt id="link-23" class="py-name"><a title="s3.objects.S3Bucket.keys
s3.service.S3Service.keys" class="py-name" href="#" onclick="return doclink('link-23', 'keys', 'link-18');">keys</a></tt></tt><tt class="py-op">.</tt><tt class="py-name">append</tt><tt class="py-op">(</tt><tt class="py-name">prefix</tt><tt class="py-op">.</tt><tt class="py-name">find</tt><tt class="py-op">(</tt><tt class="py-string">'{%s}Prefix'</tt> <tt class="py-op">%</tt> <tt id="link-24" class="py-name"><a title="s3.parsers.xmlns" class="py-name" href="#" onclick="return doclink('link-24', 'xmlns', 'link-1');">xmlns</a></tt></tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">text</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno">106</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt id="link-25" class="py-name"><a title="s3.objects.S3Bucket.keys
s3.service.S3Service.keys" class="py-name" href="#" onclick="return doclink('link-25', 'keys', 'link-18');">keys</a></tt></tt> </tt>
</div><tt class="py-lineno">107</tt>  <tt class="py-line"> </tt><script type="text/javascript">
<!--
expandto(location.href);
// -->
</script>
</pre>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="s3-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">Generated by Epydoc
        3.0alpha3 on Wed Sep 20 12:10:44 2006</td>
    <td align="right" class="footer">
      <a href="http://epydoc.sourceforge.net">http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie()
  // -->
</script>
  
</body>
</html>
